﻿<%@ Page Title="收货地址" Language="C#" MasterPageFile="~/member/mMenber.master" AutoEventWireup="true" CodeBehind="ReceiveItemAddress.aspx.cs" Inherits="map.member.ReceiveItemAddress" %>

<%@ Register Assembly="System.Web.DynamicData, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.DynamicData" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head2" runat="server">            
   <style type="text/css">
       .mainContentDiv
       {
           width:90%;
           border:solid 1px lightblue;
       }
       .box
       {
           margin:5px 5px 15px 5px; 
       }
       .td0
       {
           width :10%;
           height:35px;
       }
       .td1
       {
           width :25%;
       }
       .td2
       {
           width :30%;
       }
       .td3
       {
           width :10%;
       }
       .td4       
       {
           width :10%;
       }
       .td5
       {
           width:15%
        }
         .CommandButton
        {
            background:url(/img/back-button_61x23.gif) no-repeat;
            height:23px;
            width:61px;
            border:none;
            cursor:pointer;
        }
        .editAddressTable
        {
            width:100%;
            background-color:#ECECEC;
            border:solid 1px LightGray;
            border-bottom:none;
        }
        .td_e_0
        {
            width:20%;
            background-color:#ECECEC;
            border-bottom:solid 1px lightGray;
            text-align:right ;
            line-height:25px;
            border-right:solid 1px lightGray;
        }
        .td_e_1
        {
            padding-left:5px;
            background-color:#ECECEC;
            text-align:left ;         
            line-height:25px;
            border-bottom:solid 1px lightGray;
        }
        .validateErrorMsg
        {
            background:url(/img/errorMsg.ico) no-repeat ;
            padding-left:20px;
            border:solid 1px red;
            font-size:smaller;
            padding:2px 2px 2px 20px;
            color:Red;
        }
        .addAddressButton
        {
            background:url(/img/zfb_040811_51.gif) no-repeat;
            width:71px;
            height:27px;
            border:none; 
            cursor:pointer ;
        }
        .saveAddressButton
        {
           background:url(/img/save_061226_01.gif) no-repeat;
            width:71px;
            height:27px;
            border:none;
            cursor:pointer ;
        }
   </style>
     <link href="../../outstyle.css" rel="stylesheet" type="text/css" />
     <script src="../../js/dropdowncontent.js" type="text/javascript"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder3" runat="server" >
    <div class="mainContentDiv">

        <div class="box">
            <table width="95%" border="0" cellspacing="0" cellpadding="0">
		        <tr>
			        <td width="2%"><img src="/img/shop_06.gif" width="56" height="62"></td>
			        <td width="98%"  style=" color:Blue; font-size:16px; padding:5px 5px 5px 5px; text-align:center;">您可以预设您的购物收货地址。</td>
		        </tr>
            </table>
        </div>
		
        <div class="box">
            <table width="100%" cellpadding="0" cellspacing="0" style=" line-height:25px; background-color:#ECECEC; border:solid 1px lightGray; border-bottom:none;">
                <tr>
                    <td class ="td0">收货人</td>
                    <td class ="td1">所在地区</td>
                    <td class ="td2">街道地址</td>
                    <td class ="td3">邮编</td>
                    <td class ="td4">电话/手机</td>   
                    <td class ="td5">操作</td>
                </tr>
            </table>
            <asp:DataList ID="MainDataList" runat="server" Width="100%" 
                onitemcommand="MainDataList_ItemCommand">
                <ItemTemplate>
                    <table width="100%" cellpadding="0" cellspacing="0" style=" line-height:25px;  border:solid 1px lightGray">
                        <tr>
                            <td class ="td0">
                                <%#Eval("cbname")%>
                            </td>
                            <td class ="td1">
                                <%#Eval("省编码").ToString() + " " + Eval("县编码").ToString() + " " + Eval("区编码").ToString() + " " + Eval("区域编码").ToString()%>
                            </td>
                            <td class ="td2">
                                <%#Eval("地址")%>
                            </td>
                            <td class ="td3">
                                <%#Eval("邮政编码")%>
                            </td>
                            <td class ="td4">
                                <%#(Eval("PhoneMobile").ToString() == string.Empty) ? "" : (Eval("PhoneMobile").ToString()+"<br/>")%>
                                <%#(Eval("Phone").ToString() == string.Empty) ? "" : (Eval("Phone").ToString() + ((Eval("PhoneLocal").ToString() == string.Empty) ? "" : ("-" + Eval("PhoneLocal").ToString())))%>
                            </td>   
                            <td class ="td5">
                                <asp:Button ID="EditButton" CssClass="CommandButton" CommandArgument=<%#Eval("RECID").ToString() %> CommandName="Edit" runat="server" Text="修改" />                                 
                                <asp:Button ID="DeleteButton"  CssClass="CommandButton" CommandArgument=<%#Eval("RECID").ToString() %> CommandName="Delete" runat="server" Text="删除" />
                            </td>
                        </tr>
                    </table>
                </ItemTemplate>
            </asp:DataList>
            
            <div id="oprResultDiv" runat="server" style=" margin:5px 5px 5px 5px; color:blue">
            </div>
        </div>
		
        <div class="box">  		
            <h2 id="createDH2" runat="server">新增收货地址</h2>
            <h2 id="modifyDH2" runat="server">修改收货地址</h2>
            <table  cellpadding="0" cellspacing="0" class ="editAddressTable">
                <tr>
                    <td class="td_e_0">
                       收货人姓名：
                    </td>
                    <td class="td_e_1">
                        <asp:TextBox ID="ReceiveNameTextBox" runat="server"></asp:TextBox> 
                        <span style="color:red">*</span>
                        
                    </td> 
                </tr>
                <tr>
                    <td class="td_e_0">
                       所在地区：
                    </td>
                    <td class="td_e_1">
                        省：
                        <asp:DropDownList Width="100px" AppendDataBoundItems="true" DataTextField="省编码" DataValueField ="省编码" ID="ProvinceDropDownList" runat="server" 
                            AutoPostBack="True" 
                            onselectedindexchanged="ProvinceDropDownList_SelectedIndexChanged">
                        </asp:DropDownList>
                        市：
                        <asp:DropDownList Width="100px" AppendDataBoundItems="true"  DataTextField="县编码" DataValueField ="县编码" ID="CityDropDownList" runat="server" 
                            AutoPostBack="True" 
                            onselectedindexchanged="CityDropDownList_SelectedIndexChanged">
                        </asp:DropDownList>
                        区：
                        <asp:DropDownList Width="100px" AppendDataBoundItems="true"  DataTextField="区编码" DataValueField ="区编码" ID="DisctictDropDownList" runat="server" 
                            AutoPostBack="True" 
                            onselectedindexchanged="DisctictDropDownList_SelectedIndexChanged">
                        </asp:DropDownList>
                        区域：
                        <asp:DropDownList Width="100px" AppendDataBoundItems="true"  DataTextField="区域编码" DataValueField ="区域编码" ID="AreaDropDownList" runat="server">
                        </asp:DropDownList>
                        <span style="color:red">*</span>
                        <a href="#">如果没有找到，可以手工添加</a>
                    </td> 
                </tr>
                <tr>
                    <td class="td_e_0">
                       街道地址：
                    </td>
                    <td class="td_e_1">
                        <asp:TextBox ID="DetailAddressTextBox" TextMode="MultiLine" Width="400px" Height="50px" runat="server"></asp:TextBox> 
                        <span style="color:red">*</span>		  
                        <span style=" color:Gray ; font-size:smaller;">(不需要重复填写省/市/区)</span>
                        <%--<asp:CustomValidator ID="CustomValidator1"  CssClass="validateErrorMsg" runat="server"  ControlToValidate="DetailAddressTextBox"  
                            ClientValidationFunction="valComments_ClientValidate"  ValidateEmptyText="true"
                            ErrorMessage="街道地址不能少于5个字"  ></asp:CustomValidator>--%>
                    </td>                                                                                                    
                </tr>
                <tr>
                    <td class="td_e_0">
                       邮政编码：
                    </td>
                    <td class="td_e_1">
                        <asp:TextBox ID="PostCodeTextBox" runat="server"></asp:TextBox>
                        <span style="color:red">*</span>		  
                        <span style=" color:Gray ; font-size:smaller;">(大陆用户必填)</span>		
                    </td> 
                </tr> 
                <tr>
                    <td class="td_e_0">
                       电话号码：
                    </td>
                    <td class="td_e_1">
                        <asp:TextBox ID="PhoneTextBox" Width="100px" MaxLength="12" runat="server"></asp:TextBox>-
                        <asp:TextBox ID="PhoneLocalTextBox"  Width="50px" runat="server"></asp:TextBox> 
                        <span style="color:blue">*</span>
                        <span style=" color:Gray; font-size:smaller; ">电话号码(区号-号码)-分机</span>		            
                    </td> 
                </tr>
                <tr>
                    <td class="td_e_0">
                       手机：
                    </td>
                    <td class="td_e_1">
                        <asp:TextBox ID="PhoneMobileTextBox" runat="server"></asp:TextBox>
                        <span style="color:blue">*</span>  
                        <span style=" color:Gray; font-size:smaller; ">电话号码和电话号码必须填一个</span>	
                    </td> 
                </tr>
            </table>
        </div>
		
        <div class="box">
            <div id="createD" style=" text-align:center;" runat="server">
                <table width="100%">
                    <tr>
                        <td style=" width:50%; text-align:right;">
                            <asp:Button ID="addAddressButton" CssClass="addAddressButton" runat="server" Text=""  OnClientClick="return true;"   OnClick="CreateImg_ServerClick"/> 
                        </td>
                        <td style=" width:50%; text-align:left;">
                            &nbsp;
                        </td>
                    </tr>
                </table>
		        
            </div>
            <div id="modifyD"  style=" text-align:center; vertical-align:top;" runat="server">
                <table width="100%">
                    <tr>
                        <td style=" width:50%; text-align:right;">
                            <asp:Button ID="saveAddressButton" CssClass="saveAddressButton" runat="server" Text=""  OnClientClick="return true;"  OnClick="ModifyImg_ServerClick"/> 		                            
                        </td>
                        <td style=" width:50%; text-align:left;">
                            <a id="A1" href="#"  runat="server" onserverclick ="CreateAddressAnchor_ServerClick">新增收货地址</a>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
		
        <input  type="hidden"   runat="server" id="currentRecidHidden" />    
       
    </div>
     <script type="text/javascript" src="../js/PageValidateUtil.js"></script>
    <script type="text/javascript">
        var idPrefix = "ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder3_";
        function detailAddressValidate() {
            var detailAddEle = document.getElementById(idPrefix + "DetailAddressTextBox");
            if (detailAddEle.value.length <= 5)
                return false;
            else
                return true;
        }
        function valComments_ClientValidate(source, args) {
            if (args.Value.length <= 5)
                args.IsValid = false;
            else
                args.IsValid = true;
        }        
        //PageValidateUtil.TextRegexValidate(idPrefix + "ReceiveNameTextBox", /^$|^(\s)+$/, "收货人姓名不能为空", "validateErrorMsg", false,2);
        //PageValidateUtil.TextRegexValidate(idPrefix + "PostCodeTextBox", /^[1-9]([0-9]{5})$/, "邮政编码为空或者格式不正确", "validateErrorMsg", true,2);
        //PageValidateUtil.TextRegexValidate(idPrefix + "DetailAddressTextBox", /^$|^(\s)+$|^.{0,5}$/, "邮政编码为空或者小于5个字符", "validateErrorMsg", false,2);
        //PageValidateUtil.initSubmitValidates(["TextRegexValidate"], [[idPrefix + "ReceiveNameTextBox", /^$|^(\s)+$/, "收货人姓名不能为空", "validateErrorMsg", false, 2]]);

        window.onload = function() {
            PageValidateUtil.initElementsValidates([idPrefix + "addAddressButton", idPrefix + "saveAddressButton"], "onclick",
                         ["TextRegexValidate", "TextRegexValidate", "TextRegexValidate", "SelectValidate", "GroupValidate"], [
                         [idPrefix + "ReceiveNameTextBox", /^$|^(\s)+$/, "收货人姓名不能为空", "validateErrorMsg", false, 2],
                         [idPrefix + "PostCodeTextBox", /^[1-9]([0-9]{5})$/, "邮政编码为空或者格式不正确", "validateErrorMsg", true, 2],
                         [idPrefix + "DetailAddressTextBox", /^$|^(\s)+$|^.{0,4}$/, "邮政编码为空或者小于5个字符", "validateErrorMsg", false, 2],
                         [idPrefix + "AreaDropDownList", "", "地区不能为空", "validateErrorMsg"],
                         [[{ id: idPrefix + 'PhoneMobileTextBox', errorMsg: '手机号码和电话号码必填一个', className: 'validateErrorMsg', type: 'regex', refFunc: /^1[3|5|8]([0-9]{9})$/, otherArg: true },
                          { id: idPrefix + 'PhoneTextBox', errorMsg: '手机号码和电话号码必填一个', className: 'validateErrorMsg', type: 'regex', refFunc: /^0[1-9]([0-9]{1,2})-[1-9]([0-9]{6,7})$/, otherArg: true}]]
                         ]);
            PageValidateUtil.initFocusValidates(["TextRegexValidate", "TextRegexValidate", "TextRegexValidate"], [
                         [idPrefix + "ReceiveNameTextBox", /^$|^(\s)+$/, "收货人姓名不能为空", "validateErrorMsg", false, 2],
                         [idPrefix + "PostCodeTextBox", /^[1-9]([0-9]{5})$/, "邮政编码为空或者格式不正确", "validateErrorMsg", true, 2],
                         [idPrefix + "DetailAddressTextBox", /^$|^(\s)+$|^.{0,4}$/, "邮政编码为空或者小于5个字符", "validateErrorMsg", false, 2]]);
//            PageValidateUtil.GroupValidate([{ id: idPrefix + 'PhoneMobileTextBox', errorMsg: '手机号码和电话号码必填一个', className: 'validateErrorMsg', type: 'regex', refFunc: /^1[3|5|8]([0-9]{9})$/, otherArg: true },
//                                            { id: idPrefix + 'PhoneTextBox', errorMsg: '手机号码和电话号码必填一个', className: 'validateErrorMsg', type: 'regex', refFunc: /^0[1-9][0-9][|[0-9]]-[1-9]([0-9]{6,7})$/, otherArg: true}]);

        }
        //PageValidateUtil.TextRegexValidate("ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder3_PhoneMobileTextBox", /^1[3|5|8]([0-9]{9})$/, "手机号码格式不正确", "validateErrorMsg");
        //PageValidateUtil.TextRegexValidate("ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder3_PhoneMobileTextBox", /^1[3|5|8]([0-9]{9})$/, "固定电话号码格式不正确", "validateErrorMsg");
        //PageValidateUtil.TextRegexValidate("ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder3_PhoneMobileTextBox", /^1[3|5|8]([0-9]{9})$/, "分机号码格式不正确", "validateErrorMsg");
    </script>
</asp:Content>
